function keys(type,lang) {
    var i;
    var j;
    var id;
    var rowslower = ["AElower","ADlower","AClower","ABlower"];
    var rowsupper = ["AEupper","ADupper","ACupper","ABupper"];
    var rowslower1 = ["AElower1","ADlower1","AClower1","ABlower1"];
    var rowsupper1 = ["AEupper1","ADupper1","ACupper1","ABupper1"];
    var idstart = ["AE0","AD0","AC0","AB0"];
    var idstart2 = ["AE","AD","AC","AB"];
    var rowend = [12,13,11,10];
    for ( j = 0; j<=3; j++) {
            if (lang==="afr") {
                    var keyslower = afrikaanskeys(rowslower[j]);
                    var keysupper = afrikaanskeys(rowsupper[j]);
                    var keyslower1 = afrikaanskeys(rowslower1[j]);
                    var keysupper1 = afrikaanskeys(rowsupper1[j]);
		    var fontstyle = "font-family:NotoSans-Regular,NotoSansEthiopic-Regular,NotoSansArabic-Regular,NotoSansNKo-Regular";
	    } else if (lang==="aka") {
		    var keyslower = akankeys(rowslower[j]);
		    var keysupper = akankeys(rowsupper[j]);
                    var keyslower1 = akankeys(rowslower1[j]);
                    var keysupper1 = akankeys(rowsupper1[j]);
		    var fontstyle = "font-family:NotoSans-Regular,NotoSansEthiopic-Regular,NotoSansArabic-Regular,NotoSansNKo-Regular";
	    } else if (lang==="amh") {
		    var keyslower = amharickeys(rowslower[j]);
		    var keysupper = amharickeys(rowsupper[j]);
                    var keyslower1 = amharickeys(rowslower1[j]);
                    var keysupper1 = amharickeys(rowsupper1[j]);
		    var fontstyle = "font-family:NotoSansEthiopic-Regular,NotoSans-Regular,NotoSansArabic-Regular,NotoSansNKo-Regular";
	    } else if (lang==="ara") {
		    var keyslower = arabickeys(rowslower[j]);
		    var keysupper = arabickeys(rowsupper[j]);
                    var keyslower1 = arabickeys(rowslower1[j]);
                    var keysupper1 = arabickeys(rowsupper1[j]);
		    var fontstyle = "font-family:NotoSansArabic-Regular,NotoSans-Regular,NotoSansEthiopic-Regular,NotoSansNKo-Regular";
            } else if (lang==="teo") {
                    var keyslower = atesokeys(rowslower[j]);
                    var keysupper = atesokeys(rowsupper[j]);
                    var keyslower1 = atesokeys(rowslower1[j]);
                    var keysupper1 = atesokeys(rowsupper1[j]);
                    var fontstyle = "font-family:NotoSansArabic-Regular,NotoSans-Regular,NotoSansEthiopic-Regular,NotoSansNKo-Regular";
           } else if (lang==="bem") {
                    var keyslower = bembakeys(rowslower[j]);
                    var keysupper = bembakeys(rowsupper[j]);
                    var keyslower1 = bembakeys(rowslower1[j]);
                    var keysupper1 = bembakeys(rowsupper1[j]);
		    var fontstyle = "font-family:NotoSans-Regular,NotoSansEthiopic-Regular,NotoSansArabic-Regular,NotoSansNKo-Regular";
	    } else if (lang==="cam") {
                    var keyslower = camerooniankeys(rowslower[j]);
		    var keysupper = camerooniankeys(rowsupper[j]);
                    var keyslower1 = camerooniankeys(rowslower1[j]);
                    var keysupper1 = camerooniankeys(rowsupper1[j]);
		    var fontstyle = "font-family:NotoSans-Regular,NotoSansEthiopic-Regular,NotoSansArabic-Regular,NotoSansNKo-Regular";
           } else if (lang==="dag") {
                    var keyslower = dagbanikeys(rowslower[j]);
                    var keysupper = dagbanikeys(rowsupper[j]);
                    var keyslower1 = dagbanikeys(rowslower1[j]);
                    var keysupper1 = dagbanikeys(rowsupper1[j]);
		    var fontstyle = "font-family:NotoSans-Regular,NotoSansEthiopic-Regular,NotoSansArabic-Regular,NotoSansNKo-Regular";
	    } else if (lang==="eng") {
		    var keyslower = englishkeys(rowslower[j]);
		    var keysupper = englishkeys(rowsupper[j]);
                    var keyslower1 = englishkeys(rowslower1[j]);
                    var keysupper1 = englishkeys(rowsupper1[j]);
		    var fontstyle = "font-family:NotoSans-Regular,NotoSansEthiopic-Regular,NotoSansArabic-Regular,NotoSansNKo-Regular";
            } else if (lang==="ewe") {
                    var keyslower = ewekeys(rowslower[j]);
		    var keysupper = ewekeys(rowsupper[j]);
                    var keyslower1 = ewekeys(rowslower1[j]);
                    var keysupper1 = ewekeys(rowsupper1[j]);
		    var fontstyle = "font-family:NotoSans-Regular,NotoSansEthiopic-Regular,NotoSansArabic-Regular,NotoSansNKo-Regular";
            } else if (lang==="ga") {
                    var keyslower = gakeys(rowslower[j]);
		    var keysupper = gakeys(rowsupper[j]);
                    var keyslower1 = gakeys(rowslower1[j]);
                    var keysupper1 = gakeys(rowsupper1[j]);
		    var fontstyle = "font-family:NotoSans-Regular,NotoSansEthiopic-Regular,NotoSansArabic-Regular,NotoSansNKo-Regular";
            } else if (lang==="hau") {
                    var keyslower = hausakeys(rowslower[j]);
		    var keysupper = hausakeys(rowsupper[j]);
                    var keyslower1 = hausakeys(rowslower1[j]);
                    var keysupper1 = hausakeys(rowsupper1[j]);
		    var fontstyle = "font-family:NotoSans-Regular,NotoSansEthiopic-Regular,NotoSansArabic-Regular,NotoSansNKo-Regular";
            } else if (lang==="igb") {
                    var keyslower = igbokeys(rowslower[j]);
		    var keysupper = igbokeys(rowsupper[j]);
                    var keyslower1 = igbokeys(rowslower1[j]);
                    var keysupper1 = igbokeys(rowsupper1[j]);
		    var fontstyle = "font-family:NotoSans-Regular,NotoSansEthiopic-Regular,NotoSansArabic-Regular,NotoSansNKo-Regular";
	    } else if (lang==="kik") {
		    var keyslower = kikuyukeys(rowslower[j]);
		    var keysupper = kikuyukeys(rowsupper[j]);
                    var keyslower1 = kikuyukeys(rowslower1[j]);
                    var keysupper1 = kikuyukeys(rowsupper1[j]);
		    var fontstyle = "font-family:NotoSans-Regular,NotoSansEthiopic-Regular,NotoSansArabic-Regular,NotoSansNKo-Regular";
            } else if (lang==="lin") {
                    var keyslower = lingalakeys(rowslower[j]);
                    var keysupper = lingalakeys(rowsupper[j]);
                    var keyslower1 = lingalakeys(rowslower1[j]);
                    var keysupper1 = lingalakeys(rowsupper1[j]);
		    var fontstyle = "font-family:NotoSans-Regular,NotoSansEthiopic-Regular,NotoSansArabic-Regular,NotoSansNKo-Regular";
	    } else if (lang==="lug") {
                    var keyslower = lugandakeys(rowslower[j]);
                    var keysupper = lugandakeys(rowsupper[j]);
                    var keyslower1 = lugandakeys(rowslower1[j]);
                    var keysupper1 = lugandakeys(rowsupper1[j]);
		    var fontstyle = "font-family:NotoSans-Regular,NotoSansEthiopic-Regular,NotoSansArabic-Regular,NotoSansNKo-Regular";
           } else if (lang==="mal") {
                    var keyslower = malikeys(rowslower[j]);
                    var keysupper = malikeys(rowsupper[j]);
                    var keyslower1 = malikeys(rowslower1[j]);
                    var keysupper1 = malikeys(rowsupper1[j]);
		    var fontstyle = "font-family:NotoSans-Regular,NotoSansEthiopic-Regular,NotoSansArabic-Regular,NotoSansNKo-Regular";
            } else if (lang==="ses") {
                    var keyslower = sesothokeys(rowslower[j]);
                    var keysupper = sesothokeys(rowsupper[j]);
                    var keyslower1 = sesothokeys(rowslower1[j]);
                    var keysupper1 = sesothokeys(rowsupper1[j]);
		    var fontstyle = "font-family:NotoSans-Regular,NotoSansEthiopic-Regular,NotoSansArabic-Regular,NotoSansNKo-Regular";
            } else if (lang==="tog") {
                    var keyslower = togokeys(rowslower[j]);
                    var keysupper = togokeys(rowsupper[j]);
                    var keyslower1 = togokeys(rowslower1[j]);
                    var keysupper1 = togokeys(rowsupper1[j]);
		    var fontstyle = "font-family:NotoSans-Regular,NotoSansEthiopic-Regular,NotoSansArabic-Regular,NotoSansNKo-Regular";
	    } else if (lang==="wol") {
		    var keyslower = wolofkeys(rowslower[j]);
		    var keysupper = wolofkeys(rowsupper[j]);
                    var keyslower1 = wolofkeys(rowslower1[j]);
                    var keysupper1 = wolofkeys(rowsupper1[j]);
		    var fontstyle = "font-family:NotoSans-Regular,NotoSansEthiopic-Regular,NotoSansArabic-Regular,NotoSansNKo-Regular";
            } else if (lang==="yor") {
                    var keyslower = yorubakeys(rowslower[j]);
		    var keysupper = yorubakeys(rowsupper[j]);
                    var keyslower1 = yorubakeys(rowslower1[j]);
                    var keysupper1 = yorubakeys(rowsupper1[j]);
		    var fontstyle = "font-family:NotoSans-Regular,NotoSansEthiopic-Regular,NotoSansArabic-Regular,NotoSansNKo-Regular";
	    }else {
		    var keyslower = englishkeys(rowslower[j]);
		    var keysupper = englishkeys(rowsupper[j]);
                    var keyslower1 = englishkeys(rowslower1[j]);
                    var keysupper1 = englishkeys(rowsupper1[j]);
		    var fontstyle = "font-family:NotoSans-Regular,NotoSansEthiopic-Regular,NotoSansArabic-Regular,NotoSansNKo-Regular";
	    }
            if (j===0) {
		    document.getElementById("TLDE").innerHTML = 
			    "<font color='Red'>"+getst(keysupper[0])+"</font>"
			    +"&nbsp;&nbsp;&nbsp;"
			    +"<font color='DarkMagenta'>"+getst(keysupper1[0])+"</font>"
			    +"<br>"
			    +"<font color='Black'>"+getst(keyslower[0])+"</font>"
			    +"&nbsp;&nbsp;&nbsp;"
			    +"<font color='DeepSkyBlue'>"+getst(keyslower1[0])+"</font>";
		    if (type==="upper") {
                                    document.getElementById("TLDE").value = keysupper[0];
                    } else if (type==="upper1") {
                                    document.getElementById("TLDE").value = keysupper1[0];
                    } else if (type==="lower1") {
                                    document.getElementById("TLDE").value = keyslower1[0];
                    } else {
                                    document.getElementById("TLDE").value = keyslower[0];
                    }
		    document.getElementById("TLDE").style = "width:40px;"+fontstyle;
		    console.log(fontstyle);
            }
	    for (i = 1; i <= rowend[j]; i++) {
		    id = idstart[j] + i;
		    if (i > 9) {
			    id = idstart2[j] + i;
		    }
		    document.getElementById(id).innerHTML = 
                            "<font color='Red'>"+getst(keysupper[i])+"</font>"
		            +"&nbsp;&nbsp;&nbsp;"
		            +"<font color='DarkMagenta'>"+getst(keysupper1[i])+"</font>"
			    +"<br>"
		            +"<font color='Black'>"+getst(keyslower[i])+"</font>"
		            +"&nbsp;&nbsp;&nbsp;"
		            +"<font color='DeepSkyBlue'>"+getst(keyslower1[i])+"</font>";
		    if (type==="upper") {
                                    document.getElementById(id).value = keysupper[i];
                    } else if (type==="upper1") {
                                    document.getElementById(id).value = keysupper1[i];
                    } else if (type==="lower1") {
                                    document.getElementById(id).value = keyslower1[i];
                    } else {
                                    document.getElementById(id).value = keyslower[i];
                    }
		    document.getElementById(id).style = fontstyle;
	    }
    }
}

function keyboard(lang) {
    document.getElementById("ShiftR").value = "ShiftOff";
    document.getElementById("ShiftL").value = "ShiftOff";
    document.getElementById("Caps").value = "CapsOff";
    keys("lower",lang);
}

function changecase(lang) {
    var CapsVal = document.getElementById("Caps").value;
    if (CapsVal === "CapsOff") {
        document.getElementById("Caps").innerHTML = 
		    '&nbsp; &nbsp;<br><font color="Red"><strong>Caps</strong></font> &nbsp;';
        document.getElementById("Caps").value = "CapsOn";
    } else {
        document.getElementById("Caps").innerHTML = 
		    '&nbsp; &nbsp;<br><font color="Red">Caps</font> &nbsp;';
        document.getElementById("Caps").value = "CapsOff";
    }
    getkeys(lang);
}

function shift(lang) {
    var shift = document.getElementById("ShiftR").value;
    if (shift === "ShiftOff") {
        document.getElementById("ShiftR").value = "ShiftOn";
        document.getElementById("ShiftL").value = "ShiftOn";
    } else {
        document.getElementById("ShiftR").value = "ShiftOff";
        document.getElementById("ShiftL").value = "ShiftOff";
    }
    getkeys(lang);
}

function altgr(lang) {
	var altgr = document.getElementById("AltGr").value;
	if (altgr === "AltGrOff") {
		document.getElementById("AltGr").value = "AltGrOn";
		document.getElementById("AltGr").innerHTML = 
			'&nbsp; &nbsp;<br><font color="DeepSkyBlue"><strong>Alt Gr</strong></font>';
	}else{
		document.getElementById("AltGr").value = "AltGrOff";
		document.getElementById("AltGr").innerHTML = 
			'&nbsp; &nbsp;<br><font color="DeepSkyBlue">Alt Gr</font>';
	}
	getkeys(lang);
}

function getst(value) {
	if (value==="") {
		var st = "&nbsp;";
	}else{
		try{
			var st = String.fromCharCode(value);
		}catch(err) {
			console.log(err);
			console.log(value);
		}
	}
	return st;
}

function getkeys(lang) {
        var altgr = document.getElementById("AltGr").value;
        var shift = document.getElementById("ShiftR").value;
        var CapsVal = document.getElementById("Caps").value;
	if (altgr==="AltGrOn") {
                if (((shift === "ShiftOff") && (CapsVal === "CapsOff")) ||
		    ((shift === "ShiftOn") && (CapsVal === "CapsOn"))){
                        keys("lower1",lang);
                }else{
                        keys("upper1",lang);
                }
        }else{
                if (((shift === "ShiftOff") && (CapsVal === "CapsOff")) ||
		    ((shift === "ShiftOn") && (CapsVal === "CapsOn"))){
                        keys("lower",lang);
                }else{
                        keys("upper",lang);
                }
        }
}
